// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#pragma once

#include <cantor/proto/parser/ast.pb.h>
#include <vector>

namespace cantor::pb::ast {
    inline constexpr cantor::pb::ast::ExprNodeClass expr_class_merge(cantor::pb::ast::ExprNodeClass a,
                                                                   cantor::pb::ast::ExprNodeClass b) {
        return static_cast<cantor::pb::ast::ExprNodeClass>(a | b);
    }

    inline constexpr cantor::pb::ast::ExprNodeClass expr_class_merge(cantor::pb::ast::ExprNodeClass a,
                                                                   cantor::pb::ast::ExprNodeClass b,
                                                                   cantor::pb::ast::ExprNodeClass c) {
        return static_cast<cantor::pb::ast::ExprNodeClass>(a | b | c);
    }

    inline constexpr cantor::pb::ast::ExprNodeClass expr_class_merge(cantor::pb::ast::ExprNodeClass a,
                                                                   cantor::pb::ast::ExprNodeClass b,
                                                                   cantor::pb::ast::ExprNodeClass c,
                                                                   cantor::pb::ast::ExprNodeClass d) {
        return static_cast<cantor::pb::ast::ExprNodeClass>(a | b | c | d);
    }

    inline constexpr cantor::pb::ast::ExprNodeClass expr_class_merge(cantor::pb::ast::ExprNodeClass a,
                                                                   cantor::pb::ast::ExprNodeClass b,
                                                                   cantor::pb::ast::ExprNodeClass c,
                                                                   cantor::pb::ast::ExprNodeClass d,
                                                                   cantor::pb::ast::ExprNodeClass e) {
        return static_cast<cantor::pb::ast::ExprNodeClass>(a | b | c | d | e);
    }

    inline constexpr cantor::pb::ast::ExprNodeClass expr_class_merge(cantor::pb::ast::ExprNodeClass a,
                                                                  cantor::pb::ast::ExprNodeClass b,
                                                                  cantor::pb::ast::ExprNodeClass c,
                                                                  cantor::pb::ast::ExprNodeClass d,
                                                                  cantor::pb::ast::ExprNodeClass e,
                                                                  cantor::pb::ast::ExprNodeClass f) {
        return static_cast<cantor::pb::ast::ExprNodeClass>(a | b | c | d | e | f);
    }

    std::vector<cantor::pb::ast::ExprNodeClass> expr_class_dispatch(cantor::pb::ast::ExprNodeClass a);

    std::vector<std::string_view> expr_class_dispatch_string(cantor::pb::ast::ExprNodeClass a);

    std::string expr_class_to_string(cantor::pb::ast::ExprNodeClass expr_class, const std::string &spliter = "|");
} // namespace cantor::pb::ast
